#include <stdio.h>
#include <string>
#include <iostream>
#include <stdint.h>
using namespace std;


typedef signed char int8_t;
typedef unsigned char   uint8_t;
typedef short  int16_t;
typedef unsigned short  uint16_t;
typedef int  int32_t;
typedef unsigned   uint32_t;
typedef long long  int64_t;
typedef unsigned long long   uint64_t;

typedef uint8_t             u1;
typedef uint16_t            u2;
typedef uint32_t            u4;
typedef uint64_t            u8;
typedef int8_t              s1;
typedef int16_t             s2;
typedef int32_t             s4;
typedef int64_t             s8;


static uint32_t ComputeHash(const string& name) {
  uint32_t hash = 0;
  uint16_t len = name.length();
  const uint8_t* str = (const uint8_t*)name.c_str();

  while (len--) {
    hash = hash * 31 + *str++;
  }

  return hash;
}

/*
 * Compute a hash code on a UTF-8 string, for use with internal hash tables.
 *
 * This may or may not be compatible with UTF-8 hash functions used inside
 * the Dalvik VM.
 *
 * The basic "multiply by 31 and add" approach does better on class names
 * than most other things tried (e.g. adler32).
 */
static u4 classDescriptorHash(const char* str)
{
    u4 hash = 1;

    while (*str != '\0')
        hash = hash * 31 + *str++;

    return hash;
}



int main(int argc, char** argv)
{
    printf("hello world!\n");
	printf("ComputeHash=%ud\n",ComputeHash("android"));
	printf("ComputeHash=%ud\n",ComputeHash("android1"));
	printf("ComputeHash=%ud\n",ComputeHash("android2"));
	printf("ComputeHash=%ud\n",ComputeHash("android12"));
	
	printf("classDescriptorHash=%ud\n",ComputeHash("android12"));
	printf("android=%ud\n",ComputeHash("android"));
    return 0;
}
